package com.yanqu.road.server.cmd.kuang;

import com.yanqu.road.entity.kuang.KuangConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.kuang.Kuang;
import com.yanqu.road.server.cmd.CrossAppointCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.kuang.CrossKuangMgr;
import com.yanqu.road.server.manager.kuang.activity.CrossKuangActivity;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;

@Cmd(code = CrossProtocol.C_CROSS_KUANG_GET_USER_ABILITY_RESULT, desc = "获取实力榜单回包")
public class CrossKuangGetUserAbilityRankResultCmd extends CrossAppointCommand {

    private Kuang.CrossKuangUserAbilityRankListRespMsg reqMsg;



    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = Kuang.CrossKuangUserAbilityRankListRespMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossKuangActivity activity = CrossKuangMgr.getActivity(reqMsg.getGroupId());
        if (activity == null) {
            ret = GameErrorCode.E_KUANG_BATTLE_ACTIVITY_NOT_FOUND;
            return;
        }
        KuangConfig config = activity.getConfig();
        if (config == null) {
            ret = GameErrorCode.E_KUANG_CONFIG_NOT_FOUND;
            return;
        }
        activity.getPatronsAbilityUserRankResult(reqMsg);
    }

    @Override
    public void sendData() {

    }
}
